#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(ll x) {
  if (x == 1)
    return;
  solve(x >> 1);
  if (x & 1)
    cout << '8';
  else
    cout << '6';
}

string solve2(ll x) {
  string ans;
  if (x == 1)
    return ans;
  while (x != 1) {
    if (x & 1)
      ans = '8' + ans;
    else
      ans = '6' + ans;
    x >>= 1;
  }
  return ans;
}
int main() {
  ll n;
  cin >> n;
  solve(n + 1);
  cout << endl;
  cout << solve2(n + 1);
  return 0;
}
